#include <stdio.h>
#include <math.h>

//https://www.nowcoder.com/practice/dc943274e8254a9eb074298fb2084703?tpId=290&tags=&title=&difficulty=0&judgeStatus=0&rp=0&sourceUrl=%2Fexam%2Foj%2Fta%3FtpId%3D290

int main() {
    int min = 0;
    int max = 0;
    int ret = 10;
    int count = 1;
    scanf("%d%d", &min, &max);
    for (int sum = 0; min <= max; min++, sum = 0) {
        int i = min;
        if (min >= ret) {
            count++;
            ret *= 10;
        }
        while (i) {
            int num = i % 10;
            sum += pow(num, count);
            i /= 10;
        }
        if (sum == min) {
            printf("%d ", min);
        }
    }
    return 0;
}